x86: stub domains and page ownership for mapping in dom0
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 18 Mar 2008 16:15:24 +0000 (16:15 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 18 Mar 2008 16:15:24 +0000 (16:15 +0000)
In the case of an ioemu stubdomain with SDL or vnc server running in
dom0, we want to have the stubdomain expose the HVM guest's video RAM
through PVFB.

However, to map the pages from dom0, xenfb uses xc_map_foreign_pages
with the stubdomain ID as domid (since that is what is advertised in
the PVFB protocol, and needed for other parts of the protocol), and
thus get_page_from_l1e() complains because the stubdomain is not the
owner of the pages.  In such case, this patch checks that the
stubdomain has privileges on the actual owner of the pages, and then
accept the mapping.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
xen/arch/x86/mm.c

index e84b185598eedeb26d35aa67a3821ea09a2f62c0..5f8e2a8b7845d3775414033bef93c44cbe5ed6ad 100644 (file)
@@ -645,6 +645,7 @@ get_page_from_l1e(
     struct page_info *page = mfn_to_page(mfn);
     uint32_t l1f = l1e_get_flags(l1e);
     struct vcpu *curr = current;
+    struct domain *owner = page_get_owner(page);
     int okay;
 
     if ( !(l1f & _PAGE_PRESENT) )
@@ -673,6 +674,16 @@ get_page_from_l1e(
         return 1;
     }
 
+    /*
+     * Let privileged domains transfer the right to map their target
+     * domain's pages. This is used to allow stub-domain pvfb export to dom0,
+     * until pvfb supports granted mappings. At that time this minor hack
+     * can go away.
+     */
+    if ( unlikely(d != owner) && (owner != NULL) &&
+         (d != curr->domain) && IS_PRIV_FOR(d, owner) )
+        d = owner;
+
     /* Foreign mappings into guests in shadow external mode don't
      * contribute to writeable mapping refcounts.  (This allows the
      * qemu-dm helper process in dom0 to map the domain's memory without